home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / PowerPlant / AGA Classes 1.2 / RadioButton / LAGARadioButton.cp < prev    next >
Text File  |  1996-06-30  |  34KB  |  914 lines

  1. // ===========================================================================
  2. //    LAGARadioButton.cp
  3. // ===========================================================================
  4. //    “Apple Grayscale Appearance” compliant Radio Button
  5. //    Copyright © 1996 Chrisoft (Christophe ANDRES)  All rights reserved.
  6. //
  7. //    You may use this source code in any application (commercial, shareware, freeware,
  8. //    postcardware, etc), but not remove this notice (no need to acknowledge the use of
  9. //    this class in the about box)
  10. //    You may not sell this source code in any form. This source code may be placed on 
  11. //    publicly accessable archive sites and source code disks. It may not be placed on 
  12. //    profit archive sites and source code disks without the permission of the author, 
  13. //    Christophe ANDRES.
  14. //    
  15. //        This source code is distributed in the hope that it will be useful,
  16. //        but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. //        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18. //
  19. //    If you make any change or improvement on this class, please send the improved/changed
  20. //    version to : chrisoft@calva.net or Christophe ANDRES
  21. //                                     20, rue Prosper Mérimée
  22. //                                     67100 STRASBOURG
  23. //                                     FRANCE
  24. //
  25. // ===========================================================================
  26. //    LAGARadioButton.h            <- double-click + Command-D to see class declaration
  27. //
  28. //    LAGARadioButton is my implementation of the “Apple Grayscale Appearance for System 7.5”
  29. //        Radio Buttons
  30. //
  31. //        This class requires AGAColors.cp to be present in your project
  32. //
  33. //        Version : 1.2
  34. //
  35. //        Change History (most recent first, date in US form : mm/dd/yy):
  36. //
  37. //                        06/30/96    ca        Public release of version 1.2
  38. //                        06/27/96    ca        Changed checks for disabled state (check on triState_On instead of triState_Off)
  39. //                                                            in order that triState_Latent state is drawn as disabled
  40. //                        06/04/96    ca        made CW9 adjustments
  41. //                                                        Increased version to 1.2
  42. //                        05/25/96    ca        Relinquish memory used by the static PixMapHandle if no radio button is used anymore
  43. //                        05/23/96    ca        Updated the below changes (M™H) to allow the usage of either the standard radio button template
  44. //                                                            or the custom LAGARadioButton template. The standard radio button template is easier for layout
  45. //                                                            because you can see the text, but you cannot define directly a mixed value radio button
  46. //                                                        Defined class_ID1 and CreateAGARadioButtonStream1 to handle the two template possibilities
  47. //                                                        Added a CPPb to "LAGARadioButton CPPb.rsrc" called LAGARadioButton1 to handle the standard
  48. //                                                            radio button template, without having to tinker the class ID
  49. //                                                        Added a static RegisterClass method to simplify the class registration
  50. //                        05/23/96    M™H        Changed the stream constructor to use the standard radio button template in Contructor
  51. //                                                            which enables to see the text put in a radio button while defining the view
  52. //                        05/16/96    ca        Increased version to 1.1
  53. //                                                        Added copy constructor
  54. //                                                        Added "on the fly" constructor
  55. //                                                        Replaced UEnvironment::HasFeature(env_SupportsColor) with PaneInColor
  56. //                                                        Added GetDescriptor and SetDescriptor
  57. //                                                        Adjusted the clipping region for the radio box, to include some points left out of M™H's
  58. //                                                            implementation
  59. //                                                        Added change history
  60. //                        05/15/96    M™H        changes proposed by Michael(tm) Hamel <mhamel@adi.co.nz>    (Thanks a lot ;)
  61. //                                                        use a static PixMapHandle for FASTER draw of the button (uses less code too)
  62. //                                                        Note : the previous drawing method is available conditionnaly by defining SLOW_AGA_RADIO_DRAW
  63. //                                                                        which uses more code, but less data (we never know who could need this ;)
  64. //                                                                        To compare speed, with M™H's method, drawing 135 radio buttons on a 9500/120
  65. //                                                                        takes around 0s20 and with the SLOW_AGA_RADIO_DRAW method, the same takes around 1s70
  66. //                        04/22/96    ca        class made available by Christophe ANDRES <chrisoft@calva.net>
  67. //                                                        (version 1.0)
  68. //
  69. //        To Do:
  70. //
  71.  
  72. #include "LAGARadioButton.h"
  73.  
  74. #include "AGAColors.h"
  75.  
  76. #include <UTextTraits.h>
  77. #include <UEnvironment.h>
  78. #include <UDrawingState.h>
  79. #include <LStream.h>
  80. #include <PP_Messages.h>
  81. #include <UDrawingUtils.h>
  82.  
  83. //-------LAGARadioButton class---------------------------------------------------------------------------------------
  84.  
  85. #define    kRadioWidth            12
  86. #define    kRadioHeight        12
  87. #define kRadioNImages     9
  88.  
  89.  
  90. #ifndef SLOW_AGA_RADIO_DRAW
  91. char LAGARadioButton::mDraw[kRadioNImages][kRadioHeight][kRadioWidth] = {
  92.                                                                                     //    OFF
  93.                                                                                     {
  94.                                                                                         { -1, -1, -1,  5, 11,  B,  B, 11,  5, -1, -1, -1 },        //    0
  95.                                                                                         { -1, -1,  B, 10,  2,  2,  2,  4, 11,  B, -1, -1 },        //    1
  96.                                                                                         { -1,  B,  4,  2,  1,  W,  W,  W,  2,  7,  B, -1 },        //    2
  97.                                                                                         {  5, 10,  2,  1,  W,  W,  1,  1,  2,  4, 11,  5 },        //    3
  98.                                                                                         { 11,  2,  1,  W,  W,  1,  1,  2,  2,  4,  7, 11 },        //    4
  99.                                                                                         {  B,  2,  W,  W,  1,  1,  2,  2,  4,  4,  7,  B },        //    5
  100.                                                                                         {  B,  2,  W,  1,  1,  2,  2,  4,  4,  5,  7,  B },        //    6
  101.                                                                                         { 11,  4,  W,  1,  2,  2,  4,  4,  5,  5,  7, 11 },        //    7
  102.                                                                                         {  5, 10,  2,  2,  2,  4,  4,  5,  5,  7, 11,  5 },        //    8
  103.                                                                                         { -1,  B,  7,  4,  4,  4,  5,  5,  7,  7,  B, -1 },        //    9
  104.                                                                                         { -1, -1,  B, 10,  7,  7,  7,  7, 11,  B, -1, -1 },        //    10
  105.                                                                                         { -1, -1, -1,  5, 11,  B,  B, 11,  5, -1, -1, -1 }
  106.                                                                                     },
  107.                                                                                     //    ON
  108.                                                                                     {
  109.                                                                                         { -1, -1, -1,  5, 12,  B,  B, 12,  5, -1, -1, -1 },
  110.                                                                                         { -1, -1, 12,  B, 11, 10, 10, 10, 11,  B, -1, -1 },
  111.                                                                                         { -1, 12, 11, 10,  8,  8,  8,  7,  7,  6,  B, -1 },
  112.                                                                                         {  5,  B, 10,  8,  B,  B,  B,  B,  6,  6, 11,  5 },
  113.                                                                                         { 12, 11,  8,  B,  B,  B,  B,  B,  B,  6,  4, 11 },
  114.                                                                                         {  B, 10,  8,  B,  B,  B,  B,  B,  B,  4,  4,  B },
  115.                                                                                         {  B, 10,  8,  B,  B,  B,  B,  B,  B,  4,  2,  B },
  116.                                                                                         { 12, 10,  7,  B,  B,  B,  B,  B,  B,  2,  W, 11 },
  117.                                                                                         {  5, 12,  7,  6,  B,  B,  B,  B,  2,  W, 11,  5 },
  118.                                                                                         { -1, 12,  6,  6,  6,  4,  4,  2,  W,  W,  B, -1 },
  119.                                                                                         { -1, -1, 12, 11,  4,  4,  2,  W, 11,  B, -1, -1 },
  120.                                                                                         { -1, -1, -1,  5, 11,  B,  B, 11,  5, -1, -1, -1 }
  121.                                                                                     },
  122.                                                                                     //    MIXED
  123.                                                                                     {
  124.                                                                                         { -1, -1, -1,  5, 11,  B,  B, 11,  5, -1, -1, -1 },
  125.                                                                                         { -1, -1,  B, 10,  2,  2,  2,  4, 11,  B, -1, -1 },
  126.                                                                                         { -1,  B,  4,  2,  1,  W,  W,  W,  2,  7,  B, -1 },
  127.                                                                                         {  5, 10,  2,  1,  W,  W,  1,  1,  2,  4, 11,  5 },
  128.                                                                                         { 11,  2,  1,  W,  W,  1,  1,  2,  2,  4,  7, 11 },
  129.                                                                                         {  B,  2,  W,  B,  B,  B,  B,  B,  B,  4,  7,  B },
  130.                                                                                         {  B,  2,  W,  B,  B,  B,  B,  B,  B,  5,  7,  B },
  131.                                                                                         { 11,  4,  W,  1,  2,  2,  4,  4,  5,  5,  7, 11 },
  132.                                                                                         {  5, 10,  2,  2,  2,  4,  4,  5,  5,  7, 11,  5 },
  133.                                                                                         { -1,  B,  7,  4,  4,  4,  5,  5,  7,  7,  B, -1 },
  134.                                                                                         { -1, -1,  B, 10,  7,  7,  7,  7, 11,  B, -1, -1 },
  135.                                                                                         { -1, -1, -1,  5, 11,  B,  B, 11,  5, -1, -1, -1 }
  136.                                                                                     },
  137.                                                                                     //    OFF Pushed
  138.                                                                                     {
  139.                                                                                         { -1, -1, -1,  5, 12,  B,  B, 12,  5, -1, -1, -1 },
  140.                                                                                         { -1, -1, 12,  B, 11, 11, 11, 11, 11,  B, -1, -1 },
  141.                                                                                         { -1, 12, 11, 11, 10, 10,  9,  9,  9,  8,  B, -1 },
  142.                                                                                         {  5,  B, 11, 10, 10,  9,  9,  8,  8,  8, 11,  5 },
  143.                                                                                         { 12, 11, 10, 10,  9,  9,  8,  8,  8,  7,  6, 11 },
  144.                                                                                         {  B, 11, 10,  9,  9,  8,  8,  8,  7,  7,  6,  B },
  145.                                                                                         {  B, 11,  9,  9,  8,  8,  8,  7,  7,  6,  6,  B },
  146.                                                                                         { 12, 11,  9,  8,  8,  8,  7,  7,  6,  6,  4, 11 },
  147.                                                                                         {  5, 12,  9,  8,  8,  7,  7,  6,  6,  4, 10,  5 },
  148.                                                                                         { -1, 11,  8,  8,  7,  7,  6,  6,  4,  4,  B, -1 },
  149.                                                                                         { -1, -1, 12, 11,  6,  6,  6,  4, 10,  B, -1, -1 },
  150.                                                                                         { -1, -1, -1,  5, 11,  B,  B, 11,  5, -1, -1, -1 }
  151.                                                                                     },
  152.                                                                                     //    ON Pushed
  153.                                                                                     {
  154.                                                                                         { -1, -1, -1,  5, 12,  B,  B, 12,  5, -1, -1, -1 },
  155.                                                                                         { -1, -1, 12,  B, 11, 11, 11, 11, 11,  B, -1, -1 },
  156.                                                                                         { -1, 12, 11, 11, 10, 10,  9,  9,  9,  8,  B, -1 },
  157.                                                                                         {  5,  B, 11, 10,  B,  B,  B,  B,  8,  8, 11,  5 },
  158.                                                                                         { 12, 11, 10,  B,  B,  B,  B,  B,  B,  7,  6, 11 },
  159.                                                                                         {  B, 11, 10,  B,  B,  B,  B,  B,  B,  7,  6,  B },
  160.                                                                                         {  B, 11,  9,  B,  B,  B,  B,  B,  B,  6,  6,  B },
  161.                                                                                         { 12, 11,  9,  B,  B,  B,  B,  B,  B,  6,  4, 11 },
  162.                                                                                         {  5, 12,  9,  8,  B,  B,  B,  B,  6,  4, 10,  5 },
  163.                                                                                         { -1, 11,  8,  8,  7,  7,  6,  6,  4,  4,  B, -1 },
  164.                                                                                         { -1, -1, 12, 11,  6,  6,  6,  4, 10,  B, -1, -1 },
  165.                                                                                         { -1, -1, -1,  5, 11,  B,  B, 11,  5, -1, -1, -1 }
  166.                                                                                     },
  167.                                                                                     //    MIXED Pushed
  168.                                                                                     {
  169.                                                                                         { -1, -1, -1,  5, 12,  B,  B, 12,  5, -1, -1, -1 },
  170.                                                                                         { -1, -1, 12,  B, 11, 11, 11, 11, 11,  B, -1, -1 },
  171.                                                                                         { -1, 12, 11, 11, 10, 10,  9,  9,  9,  8,  B, -1 },
  172.                                                                                         {  5,  B, 11, 10, 10,  9,  9,  8,  8,  8, 11,  5 },
  173.                                                                                         { 12, 11, 10, 10,  9,  9,  8,  8,  8,  7,  6,  B },
  174.                                                                                         {  B, 11, 10,  B,  B,  B,  B,  B,  B,  7,  6,  B },
  175.                                                                                         {  B, 11,  9,  B,  B,  B,  B,  B,  B,  6,  6,  B },
  176.                                                                                         { 12, 11,  9,  8,  8,  8,  7,  7,  6,  6,  4, 11 },
  177.                                                                                         {  5, 12,  9,  8,  8,  7,  7,  6,  6,  4, 10,  5 },
  178.                                                                                         { -1, 11,  8,  8,  7,  7,  6,  6,  4,  4,  B, -1 },
  179.                                                                                         { -1, -1, 12, 11,  6,  6,  6,  4, 10,  B, -1, -1 },
  180.                                                                                         { -1, -1, -1,  5, 11,  B,  B, 11,  5, -1, -1, -1 }
  181.                                                                                     },
  182.                                                                                     //    OFF Disabled
  183.                                                                                     {
  184.                                                                                         { -1, -1, -1,  4,  7,  7,  7,  7,  4, -1, -1, -1 },
  185.                                                                                         { -1, -1,  7,  7,  1,  1,  1,  3,  7,  7, -1, -1 },
  186.                                                                                         { -1,  7,  3,  1,  W,  W,  W,  W,  1,  5,  7,  2 },
  187.                                                                                         {  4,  7,  1,  W,  W,  W,  W,  W,  1,  3,  7,  4 },
  188.                                                                                         {  7,  1,  W,  W,  W,  W,  W,  1,  1,  3,  5,  7 },
  189.                                                                                         {  7,  1,  W,  W,  W,  W,  1,  1,  3,  3,  5,  7 },
  190.                                                                                         {  7,  1,  W,  W,  W,  1,  1,  3,  3,  4,  5,  7 },
  191.                                                                                         {  7,  3,  W,  W,  1,  1,  3,  3,  4,  4,  5,  7 },
  192.                                                                                         {  4,  7,  1,  1,  1,  3,  3,  4,  4,  5,  7,  4 },
  193.                                                                                         { -1,  7,  5,  3,  3,  3,  4,  4,  5,  5,  7, -1 },
  194.                                                                                         { -1, -1,  7,  7,  5,  5,  5,  5,  7,  7, -1, -1 },
  195.                                                                                         { -1, -1, -1,  4,  7,  7,  7,  7,  4, -1, -1, -1 }
  196.                                                                                     },
  197.                                                                                     //    ON Disabled
  198.                                                                                     {
  199.                                                                                         { -1, -1, -1,  2,  7,  7,  7,  7,  2, -1, -1, -1 },
  200.                                                                                         { -1, -1,  7,  7,  5,  5,  5,  5,  5,  7, -1, -1 },
  201.                                                                                         { -1,  7,  5,  5,  4,  4,  4,  3,  3,  3,  7, -1 },
  202.                                                                                         {  2,  7,  5,  4,  8,  8,  8,  8,  3,  3,  5,  2 },
  203.                                                                                         {  7,  5,  4,  8,  8,  8,  8,  8,  8,  3,  1,  5 },
  204.                                                                                         {  7,  5,  4,  8,  8,  8,  8,  8,  8,  1,  1,  7 },
  205.                                                                                         {  7,  5,  4,  8,  8,  8,  8,  8,  8,  1,  W,  7 },
  206.                                                                                         {  7,  5,  3,  8,  8,  8,  8,  8,  8,  W,  W,  5 },
  207.                                                                                         {  2,  5,  3,  3,  8,  8,  8,  8,  W,  W,  5,  2 },
  208.                                                                                         { -1,  7,  3,  3,  3,  1,  1,  W,  W,  5,  7, -1 },
  209.                                                                                         { -1, -1,  7,  7,  1,  1,  W,  W,  5,  7, -1, -1 },
  210.                                                                                         { -1, -1, -1,  2,  5,  7,  7,  5,  2, -1, -1, -1 }
  211.                                                                                     },
  212.                                                                                     //    MIXED Disabled
  213.                                                                                     {
  214.                                                                                         { -1, -1, -1,  4,  7,  7,  7,  7,  4, -1, -1, -1 },
  215.                                                                                         { -1, -1,  7,  7,  1,  1,  1,  3,  7,  7, -1, -1 },
  216.                                                                                         { -1,  7,  3,  1,  W,  W,  W,  W,  1,  5,  7, -1 },
  217.                                                                                         {  4,  7,  1,  W,  W,  W,  W,  W,  1,  3,  7,  4 },
  218.                                                                                         {  7,  1,  W,  W,  W,  W,  W,  1,  1,  3,  5,  7 },
  219.                                                                                         {  7,  1,  W,  8,  8,  8,  8,  8,  8,  3,  5,  7 },
  220.                                                                                         {  7,  1,  W,  8,  8,  8,  8,  8,  8,  4,  5,  7 },
  221.                                                                                         {  7,  3,  W,  W,  1,  1,  3,  3,  4,  4,  5,  7 },
  222.                                                                                         {  4,  7,  1,  1,  1,  3,  3,  4,  4,  5,  7,  4 },
  223.                                                                                         { -1,  7,  5,  3,  3,  3,  4,  4,  5,  5,  7, -1 },
  224.                                                                                         { -1, -1,  7,  7,  5,  5,  5,  5,  7,  7, -1, -1 },
  225.                                                                                         { -1, -1, -1,  4,  7,  7,  7,  7,  4, -1, -1, -1 }
  226.                                                                                     }
  227.                                                                         };
  228.  
  229. //    begin    <05/15/96    M™H>
  230. RgnHandle LAGARadioButton::mRadioClip = nil;
  231. PixMapHandle LAGARadioButton::mImages = nil;
  232. long LAGARadioButton::mUsage = 0;                                                                                                                                                        //    <05/25/96 ca>
  233.  
  234. // static
  235. void LAGARadioButton::Initialise ()
  236. // Manufacture a 24-bit deep PixMapHandle with the nine radio button images in it
  237. // and a circular clipping region for use with CopyBits
  238. {
  239.     Ptr                 bitsP;
  240.     Int32                n,i,j;
  241.     char                 color;
  242.     Rect                 radioSpace;
  243.     PixMapPtr     pmp;
  244.     Int32*             scanP;
  245.     
  246.     // Make a PixMapHandle for the images
  247.     bitsP = ::NewPtr(kRadioNImages * kRadioWidth * kRadioHeight * 4);
  248.     ThrowIfMemFail_(bitsP);
  249.     mImages = ::NewPixMap();
  250.     ::HLockHi(Handle(mImages));
  251.     pmp = *mImages;
  252.     pmp->baseAddr = bitsP;
  253.     pmp->rowBytes = 0x8000 + kRadioNImages * kRadioWidth * 4;
  254.     pmp->bounds.left = 0;
  255.     pmp->bounds.right = kRadioNImages * kRadioWidth;
  256.     pmp->bounds.top = 0;
  257.     pmp->bounds.bottom = kRadioHeight;
  258.     pmp->pmVersion = 0;
  259.     pmp->pixelType = RGBDirect;
  260.     pmp->pixelSize = 32;
  261.     pmp->cmpCount = 3;
  262.     pmp->cmpSize = 8;
  263.     pmp->planeBytes = 0;
  264.     ::DisposeCTable(pmp->pmTable);
  265.     pmp->pmTable = nil;
  266.     pmp->pmReserved = 0;
  267.     
  268.     // Fill it with the pixel array
  269.     scanP = (Int32*)bitsP;
  270.     for (i=0; i < kRadioHeight; i++)
  271.         for (n=0; n < kRadioNImages; n++)
  272.             for (j=0; j < kRadioWidth; j++)
  273.                 {
  274.                     color = mDraw[n][i][j];
  275.                     if (color == -1)
  276.                         *scanP++ = 0; // Clipped anyway
  277.                     else
  278.                         *scanP++ = ((((Int32)gAGAColorArray[color].red)<<8) & 0xFF0000)
  279.                                             +((gAGAColorArray[color].green) & 0xFF00)
  280.                                             +((gAGAColorArray[color].blue>>8) & 0xFF);
  281.                 }
  282.  
  283.     // Make a circular clipping region
  284.     ::SetRect(&radioSpace, 0, 0, kRadioWidth, kRadioHeight);
  285.     mRadioClip = ::NewRgn();
  286.     ::OpenRgn();
  287.     ::FrameOval(&radioSpace);
  288.     ::CloseRgn(mRadioClip);
  289.  
  290.         //    begin    <05/16/96    ca>
  291.     // adjust clipping region to include edge points which if not included make the radio button look ugly
  292.     RgnHandle aRgn = NewRgn();
  293.     ::OpenRgn();
  294.     ::SetRect(&radioSpace, 3, 0, 9, kRadioHeight);
  295.     ::FrameRect(&radioSpace);
  296.     ::SetRect(&radioSpace, 0, 3, kRadioWidth, 9);
  297.     ::FrameRect(&radioSpace);
  298.     ::CloseRgn(aRgn);
  299.     ::UnionRgn(mRadioClip, aRgn, mRadioClip);
  300.     ::DisposeRgn(aRgn);
  301.         //    end    <05/16/96    ca>
  302. }
  303. //    end    <05/15/96    M™H>
  304. #endif /*!SLOW_AGA_RADIO_DRAW*/
  305.  
  306. // begin <05/23/96 ca>
  307. void LAGARadioButton::RegisterClass ()
  308.  
  309. {
  310.     //    Constructing the class with the LAGARadioButton CPPb
  311.     URegistrar::RegisterClass(LAGARadioButton::class_ID, (ClassCreatorFunc)LAGARadioButton::CreateAGARadioButtonStream);
  312.     //    Constructing the class with the standard radio button template or the LAGARadioButton1 CPPb
  313.     URegistrar::RegisterClass(LAGARadioButton::class_ID1, (ClassCreatorFunc)LAGARadioButton::CreateAGARadioButtonStream1);
  314. }
  315.  
  316. LAGARadioButton* LAGARadioButton::CreateAGARadioButtonStream (LStream *inStream)
  317.  
  318. {
  319.     //    Constructing from a 'AGA2' template
  320.     return(new LAGARadioButton(inStream));
  321. }
  322.  
  323. LAGARadioButton* LAGARadioButton::CreateAGARadioButtonStream1 (LStream *inStream)
  324.  
  325. {
  326.     //    Constructing from a 'AgA2' template
  327.     return(new LAGARadioButton(inStream, true));
  328. }
  329. //    end <05/23/96 ca>
  330.  
  331. //-------Constructors-------------------------------------------------------------------------------------------------
  332.  
  333. LAGARadioButton::LAGARadioButton ()
  334.  
  335. {
  336.     mTitle = "\p";
  337.     SetMaxValue(2);        //    2 is for mixed value Radio buttons
  338.  
  339. #ifndef SLOW_AGA_RADIO_DRAW
  340.     mUsage++;                                                                                                                                                                                //    <05/25/96 ca>
  341.     if (mImages==nil)                                                                                                                                                                //    <05/15/96    M™H>
  342.         Initialise();
  343. #endif /*!SLOW_AGA_RADIO_DRAW*/
  344. }
  345.  
  346. LAGARadioButton::LAGARadioButton (LStream *inStream, Boolean inCreateWithRadioButton) : LControl(inStream)
  347.  
  348. {
  349.     if (inCreateWithRadioButton)                                                                                                                                        //    <05/23/96 ca>
  350.         {
  351.             // begin <05/23/96 M™H> mod so we can use standard radio button template
  352.             Int16        controlKind;
  353.             Int32        macRefCon;
  354.             
  355.             inStream->ReadData(&controlKind, sizeof(Int16));                    //    Ignored
  356.             inStream->ReadData(&mTextTraitsID, sizeof(ResIDT));
  357.             inStream->ReadPString(mTitle);
  358.             inStream->ReadData(&macRefCon, sizeof(Int32));                        //    Ignored
  359.             // end <05/23/96 M™H> mod
  360.         }
  361.     else
  362.         {
  363.             inStream->ReadData(&mTextTraitsID, sizeof(ResIDT));
  364.             inStream->ReadPString(mTitle);
  365.         }
  366.  
  367.     if (mMaxValue < 2)
  368.         SetMaxValue(2);
  369.  
  370. #ifndef SLOW_AGA_RADIO_DRAW
  371.     mUsage++;                                                                                                                                                                                //    <05/25/96 ca>
  372.     if (mImages==nil)                                                                                                                                                                //    <05/15/96    M™H>
  373.         Initialise();
  374. #endif /*!SLOW_AGA_RADIO_DRAW*/
  375. }
  376.  
  377. //    begin    <05/16/96    ca>
  378. LAGARadioButton::LAGARadioButton (const LAGARadioButton &inOriginal)
  379.  
  380. {
  381.     mTextTraitsID = inOriginal.mTextTraitsID;
  382.     mTitle = inOriginal.mTitle;
  383.     
  384.     if (mMaxValue < 2)
  385.         SetMaxValue(2);
  386.  
  387. #ifndef SLOW_AGA_RADIO_DRAW
  388.     mUsage++;                                                                                                                                                                                //    <05/25/96 ca>
  389.     if (mImages==nil)    //    But since we copy a LAGARadioButton, mImages MUST already be initialized ;)        <05/15/96    M™H>
  390.         Initialise();
  391. #endif /*!SLOW_AGA_RADIO_DRAW*/
  392. }
  393.  
  394. LAGARadioButton::LAGARadioButton (const SPaneInfo &inPaneInfo, MessageT inValueMessage, Int32 inValue,
  395.                                                                     ResIDT inTextTraitsID, Str255 inTitle) : LControl(inPaneInfo, inValueMessage, inValue, 0, 2)
  396. {
  397.     mTextTraitsID = inTextTraitsID;
  398.     mTitle = inTitle;
  399.  
  400. #ifndef SLOW_AGA_RADIO_DRAW
  401.     mUsage++;                                                                                                                                                                                //    <05/25/96 ca>
  402.     if (mImages==nil)                                                                                                                                                                //    <05/15/96    M™H>
  403.         Initialise();
  404. #endif /*!SLOW_AGA_RADIO_DRAW*/
  405. }
  406. //    end    <05/16/96    ca>
  407.  
  408. LAGARadioButton::~LAGARadioButton ()
  409.  
  410. {
  411. #ifndef SLOW_AGA_RADIO_DRAW                                                                                                                                                //    begin <05/25/96    ca>
  412.     mUsage--;
  413.     if (!mUsage)
  414.         {
  415.             if (mRadioClip != nil)
  416.                 {
  417.                     ::DisposeRgn(mRadioClip);
  418.                     mRadioClip = nil;
  419.                 }
  420.             if (mImages != nil)
  421.                 {
  422.                     ::DisposePixMap(mImages);
  423.                     mImages = nil;
  424.                 }
  425.         }
  426. #endif /*!SLOW_AGA_RADIO_DRAW*/                                                                                                                                            //    end <05/25/96    ca>
  427. }
  428.  
  429. //-------Drawers----------------------------------------------------------------------------------------------------
  430.  
  431. void LAGARadioButton::DrawSelf ()
  432.  
  433. {
  434.     DrawGraphic();
  435.     DrawText();
  436. }
  437.  
  438. void LAGARadioButton::DrawGraphic (Boolean inPushed)
  439.  
  440. {
  441.     StColorPenState theState;
  442.     Rect frame;
  443.     Boolean hasColor = ::PaneInColor(this);
  444.     Boolean disabled = (mEnabled != triState_On);                                                                                                            //    <06/27/96    ca>
  445.     
  446.     theState.Normalize();
  447.     
  448.     CalcLocalFrameRect(frame);
  449.     frame.right = frame.left + kRadioWidth;
  450.     frame.bottom = frame.top + kRadioHeight;
  451.  
  452.     if (hasColor)
  453.         {
  454. #ifndef SLOW_AGA_RADIO_DRAW
  455.             short pattern = (mValue ? (mValue == 1 ? 1 : 2) : 0) + (disabled ? 6 : (inPushed ? 3 : 0));
  456.             //    begin    <05/15/96    M™H>
  457.             Rect srcRect;
  458.             GrafPtr thisPort;
  459.             
  460.             srcRect.left = pattern*12;
  461.             srcRect.top = 0;
  462.             srcRect.right = srcRect.left + kRadioWidth;
  463.             srcRect.bottom = kRadioHeight;
  464.             ::OffsetRgn(mRadioClip, frame.left-(**mRadioClip).rgnBBox.left, frame.top-(**mRadioClip).rgnBBox.top); 
  465.             ::GetPort(&thisPort);
  466.             ::CopyBits((BitMapPtr)*mImages, &thisPort->portBits, &srcRect, &frame, srcCopy, mRadioClip);
  467.             //    end <05/15/96    M™H>
  468. #else /*!SLOW_AGA_RADIO_DRAW*/
  469.             if (!disabled)
  470.                 {
  471.                     ::MoveTo(frame.left + 6, frame.top);
  472.                     ::Line(1, 0);
  473.                     ::Move(3, 1);        ::Line(1, 1);
  474.                     ::Move(1, 3);        ::Line(0, 1);
  475.                     ::Move(-1, 3);    ::Line(-1, 1);
  476.                     ::Move(-3, 1);    ::Line(-1, 0);
  477.                     ::Move(-3, -1);    ::Line(-1, -1);
  478.                     ::Move(-1, -3);    ::Line(0, -1);
  479.                     ::Move(1, -3);    ::Line(1, -1);
  480.                     ::RGBForeColor(&gAGAColorArray[5]);
  481.                     ::Move(1, -1);    ::Line(0, 0);
  482.                     ::Move(5, 0);        ::Line(0, 0);
  483.                     ::Move(3, 3);        ::Line(0, 0);
  484.                     ::Move(0, 5);        ::Line(0, 0);
  485.                     ::Move(-3, 3);    ::Line(0, 0);
  486.                     ::Move(-5, 0);    ::Line(0, 0);
  487.                     ::Move(-3, -3);    ::Line(0, 0);
  488.                     ::Move(0, -5);    ::Line(0, 0);
  489.                     if (!inPushed)
  490.                         {
  491.                             if (mValue != 1)
  492.                                 {
  493.                                     ::RGBForeColor(&gAGAColorArray[11]);
  494.                                     ::Move(4, -3);        ::Line(0, 0);
  495.                                     ::Move(3, 0);        ::Line(1, 1);
  496.                                     ::Move(2, 2);        ::Line(1, 1);
  497.                                     ::Move(0, 3);        ::Line(-1, 1);
  498.                                     ::Move(-2, 2);    ::Line(-1, 1);
  499.                                     ::Move(-3, 0);    ::Line(0, 0);
  500.                                     ::Move(-4, -4);    ::Line(0, 0);
  501.                                     ::Move(0, -3);    ::Line(0, 0);
  502.                                     ::RGBForeColor(&gAGAColorArray[2]);
  503.                                     ::Move(1, 2);        ::Line(0, -2);
  504.                                     ::Line(3, -3);    ::Line(2, 0);
  505.                                     ::Move(2, 1);        ::Line(0, 1);
  506.                                     ::Line(-5, 5);
  507.                                     ::Move(-1, 0);    ::Line(2, 0);
  508.                                     ::Line(4, -4);
  509.                                     ::RGBForeColor(&gAGAColorArray[1]);
  510.                                     ::Move(-1, -1);    ::Line(-1, 0);
  511.                                     ::Move(0, 1);        ::Line(-1, 0);
  512.                                     ::Move(0, 1);        ::Line(-1, 0);
  513.                                     ::Move(0, 1);        ::Line(-1, 0);
  514.                                     ::Move(0, 1);        ::Line(0, 0);
  515.                                     ::Move(-1, -3);    ::Line(2, -2);
  516.                                     ::ForeColor(whiteColor);
  517.                                     ::Move(3, 0);        ::Line(-2, 0);
  518.                                     ::Move(0, 1);        ::Line(-1, 0);
  519.                                     ::Move(0, 1);        ::Line(-1, 0);
  520.                                     ::Move(0, 1);        ::Line(-1, 0);
  521.                                     ::Line(0, 2);
  522.                                     ::RGBForeColor(&gAGAColorArray[7]);
  523.                                     ::Move(0, 2);        ::Line(0, 0);
  524.                                     ::Move(2, 1);        ::Line(3, 0);
  525.                                     ::Move(1, -1);    ::Line(1, 0);
  526.                                     ::Move(0, -1);    ::Line(1, -1);
  527.                                     ::Line(0, -3);
  528.                                     ::Move(-1, -2);    ::Line(0, 0);
  529.                                     ::RGBForeColor(&gAGAColorArray[4]);
  530.                                     ::Move(0, 1);        ::Line(0, 2);
  531.                                     ::Line(-4, 4);    ::Line(-2, 0);
  532.                                     ::Move(2, -1);    ::Line(3, -3);
  533.                                     ::Move(-1, -4);    ::Line(0, 0);
  534.                                     ::Move(-5, 1);    ::Line(0, 0);
  535.                                     ::Move(-1, 5);    ::Line(0, 0);
  536.                                     ::RGBForeColor(&gAGAColorArray[10]);
  537.                                     ::Move(0, 1);        ::Line(0, 0);
  538.                                     ::Move(2, 2);        ::Line(0, 0);
  539.                                     ::Move(-2, -7);    ::Line(0, 0);
  540.                                     ::Move(2, -2);    ::Line(0, 0);
  541.                                     ::RGBForeColor(&gAGAColorArray[5]);
  542.                                     ::Move(6, 5);        ::Line(-3, 3);
  543.                                     ::Move(1, 0);        ::Line(2, -2);
  544.                                     if (mValue)
  545.                                         {
  546.                                             ::ForeColor(blackColor);
  547.                                             ::Move(-1, -1); ::Line(-5, 0);
  548.                                             ::Move(0, -1);    ::Line(5, 0);
  549.                                         }
  550.                                 }
  551.                             else
  552.                                 {
  553.                                     ::RGBForeColor(&gAGAColorArray[12]);
  554.                                     ::Move(1, -1);    ::Line(1, -1);
  555.                                     ::Move(2, -1);    ::Line(0, 0);
  556.                                     ::Move(3, 0);        ::Line(0, 0);
  557.                                     ::Move(-5, 10);    ::Line(-1, -1);
  558.                                     ::Line(0, -1);    ::Line(-1, -1);
  559.                                     ::Move(0, -3);    ::Line(0, 0);
  560.                                     ::RGBForeColor(&gAGAColorArray[11]);
  561.                                     ::Move(1, 0);        ::Line(0, 0);
  562.                                     ::Move(1, -2);    ::Line(0, 0);
  563.                                     ::Move(2, -1);    ::Line(0, 0);
  564.                                     ::Move(4, 0);        ::Line(0, 0);
  565.                                     ::Move(2, 2);        ::Line(1, 1);
  566.                                     ::Move(0, 3);        ::Line(-1, 1);
  567.                                     ::Move(-2, 2);    ::Line(-1, 1);
  568.                                     ::Move(-3, 0);    ::Line(-1, -1);
  569.                                     ::RGBForeColor(&gAGAColorArray[10]);
  570.                                     ::Move(-2, -3);    ::Line(0, -2);
  571.                                     ::Move(1, -2);    ::Line(1, -1);
  572.                                     ::Move(2, -1);    ::Line(2, 0);
  573.                                     ::RGBForeColor(&gAGAColorArray[8]);
  574.                                     ::Move(-1, 1);    ::Line(-2, 0);
  575.                                     ::Line(-2, 2);    ::Line(0, 2);
  576.                                     ::RGBForeColor(&gAGAColorArray[7]);
  577.                                     ::Move(0, 1);        ::Line(0, 1);
  578.                                     ::Move(5, -6);    ::Line(1, 0);
  579.                                     ::RGBForeColor(&gAGAColorArray[6]);
  580.                                     ::Move(0, 1);        ::Line(1, -1);
  581.                                     ::Line(0, 2);
  582.                                     ::Move(-5, 5);    ::Line(-2, 0);
  583.                                     ::Line(1, -1);
  584.                                     ::RGBForeColor(&gAGAColorArray[4]);
  585.                                     ::Move(1, 2);        ::Line(1, 0);
  586.                                     ::Move(0, -1);    ::Line(1, 0);
  587.                                     ::Move(3, -3);    ::Line(0, -1);
  588.                                     ::Move(1, 0);        ::Line(0, -1);
  589.                                     ::RGBForeColor(&gAGAColorArray[2]);
  590.                                     ::Move(0, 2);        ::Line(-4, 4);
  591.                                     ::ForeColor(whiteColor);
  592.                                     ::Move(1, 0);        ::Line(3, -3);
  593.                                     ::Move(-1 ,2);    ::Line(0, 0);
  594.                                     ::ForeColor(blackColor);
  595.                                     ::Move(-8, -6);    ::Line(0, 0);
  596.                                     ::Move(2, -2);    ::Line(0, 0);
  597.                                     ::Move(0, 3);        ::Line(0, 3);
  598.                                     ::Move(1, 1);        ::Line(0, -5);
  599.                                     ::Move(1, 0);        ::Line(0, 5);
  600.                                     ::Move(1, 0);        ::Line(0, -5);
  601.                                     ::Move(1, 0);        ::Line(0, 5);
  602.                                     ::Move(1, -1);    ::Line(0, -3);
  603.                                 }
  604.                         }
  605.                     else
  606.                         {
  607.                             ::RGBForeColor(&gAGAColorArray[12]);
  608.                             ::Move(1, -1);    ::Line(1, -1);
  609.                             ::Move(2, -1);    ::Line(0, 0);
  610.                             ::Move(3, 0);        ::Line(0, 0);
  611.                             ::Move(-5, 10);    ::Line(0, 0);
  612.                             ::Move(-1, -2);    ::Line(-1, -1);
  613.                             ::Move(0, -3);    ::Line(0, 0);
  614.                             ::RGBForeColor(&gAGAColorArray[11]);
  615.                             ::Move(1, 3);        ::Line(0, -3);
  616.                             ::Line(1, -1);    ::Line(0, -1);
  617.                             ::Line(1, 0);        ::Line(1, -1);
  618.                             ::Line(4, 0);
  619.                             ::Move(2, 2);        ::Line(1, 1);
  620.                             ::Move(0, 3);        ::Line(0, 0);
  621.                             ::Move(-4, 4);    ::Line(0, 0);
  622.                             ::Move(-3, 0);    ::Line(-1, -1);
  623.                             ::Move(-2, -1);    ::Line(0, 0);
  624.                             ::RGBForeColor(&gAGAColorArray[10]);
  625.                             ::Move(1, -4);    ::Line(0, -1);
  626.                             ::Move(1, 0);        ::Line(0, -1);
  627.                             ::Move(1, 0);        ::Line(0, -1);
  628.                             ::Line(1, 0);
  629.                             ::Move(5, 6);        ::Line(0, 0);
  630.                             ::Move(-2, 2);    ::Line(0, 0);
  631.                             ::RGBForeColor(&gAGAColorArray[9]);
  632.                             ::Move(-6, -2);    ::Line(0, -1);
  633.                             ::Line(5, -5);    ::Line(1, 0);
  634.                             ::Move(-2, 0);    ::Line(-4, 4);
  635.                             ::RGBForeColor(&gAGAColorArray[8]);
  636.                             ::Move(1, 1);        ::Line(4, -4);
  637.                             ::Move(2, -1);    ::Line(-7, 7);
  638.                             ::Move(1, 0);        ::Line(6, -6);
  639.                             ::RGBForeColor(&gAGAColorArray[7]);
  640.                             ::Move(0, 1);        ::Line(-5, 5);
  641.                             ::Move(1, 0);        ::Line(4, -4);
  642.                             ::RGBForeColor(&gAGAColorArray[6]);
  643.                             ::Move(1, -1);    ::Line(0, 2);
  644.                             ::Line(-4, 4);    ::Line(-2, 0);
  645.                             ::Move(1, 0);        ::Line(4, -4);
  646.                             ::RGBForeColor(&gAGAColorArray[4]);
  647.                             ::Move(1, 1);        ::Line(-3, 3);
  648.                             ::Move(2, -1);    ::Line(0, 0);
  649.                             ::ForeColor(blackColor);
  650.                             ::Move(-8, -6);    ::Line(0, 0);
  651.                             ::Move(2, -2);    ::Line(0, 0);
  652.                             if (mValue)
  653.                                 if (mValue == 1)
  654.                                     {
  655.                                         ::Move(0, 3);    ::Line(0, 3);
  656.                                         ::Move(1, 1);        ::Line(0, -5);
  657.                                         ::Move(1, 0);        ::Line(0, 5);
  658.                                         ::Move(1, 0);        ::Line(0, -5);
  659.                                         ::Move(1, 0);        ::Line(0, 5);
  660.                                         ::Move(1, -1);    ::Line(0, -3);
  661.                                     }
  662.                                 else
  663.                                     {
  664.                                         ::Move(0, 4);        ::Line(5, 0);
  665.                                         ::Move(0, 1);        ::Line(-5 ,0);
  666.                                     }
  667.                         }
  668.                 }
  669.             else
  670.                 {
  671.                     ::RGBForeColor(&gAGAColorArray[7]);
  672.                     ::MoveTo(frame.left + 5, frame.top);
  673.                     ::Line(3, 0);        ::Line(1, 1);
  674.                     ::Line(1, 0);        ::Line(1, 1);
  675.                     ::Line(0, 1);        ::Line(1, 1);
  676.                     ::Line(0, 3);        ::Line(-1, 1);
  677.                     ::Line(0, 1);        ::Line(-1, 1);
  678.                     ::Line(-1, 0);    ::Line(-1, 1);
  679.                     ::Line(-3, 0);    ::Line(-1, -1);
  680.                     ::Line(-1, 0);    ::Line(-1, -1);
  681.                     ::Line(0, -1);    ::Line(-1, -1);
  682.                     ::Line(0, -3);    ::Line(1, -1);
  683.                     ::Line(0, -1);    ::Line(1, -1);
  684.                     ::Line(1, 0);
  685.                     if (mValue != 1)
  686.                         {
  687.                             ::RGBForeColor(&gAGAColorArray[4]);
  688.                             ::Move(0, -1);    ::Line(0, 0);
  689.                             ::Move(5, 0);        ::Line(0, 0);
  690.                             ::Move(3, 3);        ::Line(0, 0);
  691.                             ::Move(0, 5);        ::Line(0, 0);
  692.                             ::Move(-2, -2);    ::Line(-3, 3);
  693.                             ::Move(1, 0);        ::Line(2, -2);
  694.                             ::Move(-1, 4);    ::Line(0, 0);
  695.                             ::Move(-5, 0);    ::Line(0, 0);
  696.                             ::Move(-3, -3);    ::Line(0, 0);
  697.                             ::Move(0, -5);    ::Line(0, 0);
  698.                             ::RGBForeColor(&gAGAColorArray[3]);
  699.                             ::Move(2, -1);    ::Line(0, 0);
  700.                             ::Move(5, -1);    ::Line(0, 0);
  701.                             ::Move(2, 2);        ::Line(0, 2);
  702.                             ::Line(-4, 4);    ::Line(-2, 0);
  703.                             ::Move(2, -1);    ::Line(3, -3);
  704.                             ::Move(-7, 2);    ::Line(0, 0);
  705.                             ::RGBForeColor(&gAGAColorArray[5]);
  706.                             ::Move(3, 3);        ::Line(3, 0);
  707.                             ::Line(3, -3);    ::Line(0, -3);
  708.                             ::Move(-1, 5);    ::Line(0, 0);
  709.                             ::Move(0, -7);    ::Line(0, 0);
  710.                             ::RGBForeColor(&gAGAColorArray[1]);
  711.                             ::Move(-1, 0);    ::Line(0, 2);
  712.                             ::Move(-1, 0);    ::Line(0, 1);
  713.                             ::Move(-1, 0);    ::Line(0, 1);
  714.                             ::Move(-1, 0);    ::Line(0, 1);
  715.                             ::Move(-1, 0);    ::Line(0, 1);
  716.                             ::Line(-2, 0);
  717.                             ::Move(-1, -2);    ::Line(0, -2);
  718.                             ::Line(3, -3);    ::Line(2, 0);
  719.                             ::ForeColor(whiteColor);
  720.                             ::Move(-2, 1);    ::Line(3, 0);
  721.                             ::Move(0, 1);        ::Line(-4, 0);
  722.                             ::Move(-1, 1);    ::Line(4, 0);
  723.                             ::Move(-1, 1);    ::Line(-3, 0);
  724.                             ::Move(0, 1);        ::Line(2, 0);
  725.                             ::Move(-1, 1);    ::Line(-1, 0);
  726.                             if (mValue)
  727.                                 {
  728.                                     ::RGBForeColor(&gAGAColorArray[8]);
  729.                                     ::Move(1, -1);     ::Line(5, 0);
  730.                                     ::Move(0, -1);    ::Line(-5, 0);
  731.                                 }
  732.                         }
  733.                     else
  734.                         {
  735.                             ::RGBForeColor(&gAGAColorArray[2]);
  736.                             ::Move(0, -1);    ::Line(0, 0);
  737.                             ::Move(5, 0);        ::Line(0, 0);
  738.                             ::Move(3, 3);        ::Line(0, 0);
  739.                             ::Move(0, 5);        ::Line(0, 0);
  740.                             ::Move(-3, 3);    ::Line(0, 0);
  741.                             ::Move(-5, 0);    ::Line(0, 0);
  742.                             ::Move(-3, -3);    ::Line(0, 0);
  743.                             ::Move(0, -5);    ::Line(0, 0);
  744.                             ::RGBForeColor(&gAGAColorArray[5]);
  745.                             ::Move(1, 5);        ::Line(0, -4);
  746.                             ::Line(1, -1);    ::Line(0, -1);
  747.                             ::Line(1, 0);        ::Line(1, -1);
  748.                             ::Line(4, 0);
  749.                             ::Move(2, 2);        ::Line(1, 1);
  750.                             ::Move(0, 3);        ::Line(-1, 1);
  751.                             ::Move(-2, 2);    ::Line(-1, 1);
  752.                             ::Move(-3, 0);    ::Line(0, 0);
  753.                             ::RGBForeColor(&gAGAColorArray[4]);
  754.                             ::Move(-2, -5);    ::Line(0, -2);
  755.                             ::Line(2, -2);    ::Line(2, 0);
  756.                             ::RGBForeColor(&gAGAColorArray[3]);
  757.                             ::Move(1, 0);        ::Line(2, 0);
  758.                             ::Move(-1, 1);    ::Line(1, 0);
  759.                             ::Move(0, 1);        ::Line(0, 0);
  760.                             ::Move(-5, 5);    ::Line(-2, 0);
  761.                             ::Move(0, -1);    ::Line(1, 0);
  762.                             ::Move(-1, -1);    ::Line(0, 0);
  763.                             ::RGBForeColor(&gAGAColorArray[1]);
  764.                             ::Move(2, 3);        ::Line(1, 0);
  765.                             ::Move(0, -1);    ::Line(1, 0);
  766.                             ::Move(3, -3);    ::Line(0, -1);
  767.                             ::Move(1, 0);        ::Line(0, -1);
  768.                             ::ForeColor(whiteColor);
  769.                             ::Move(0, 2);        ::Line(0, 1);
  770.                             ::Move(-1, 0);    ::Line(0, 2);
  771.                             ::Move(-1, -1);    ::Line(0, 1);
  772.                             ::Move(-1, 0);    ::Line(0, 1);
  773.                             ::Move(-1, 0);    ::Line(0, 0);
  774.                             ::RGBForeColor(&gAGAColorArray[8]);
  775.                             ::Move(-3, -3);    ::Line(0, -3);
  776.                             ::Move(1, -1);    ::Line(0, 5);
  777.                             ::Move(1, 0);        ::Line(0, -5);
  778.                             ::Move(1, 0);        ::Line(0, 5);
  779.                             ::Move(1, 0);        ::Line(0, -5);
  780.                             ::Move(1, 1);        ::Line(0, 3);
  781.                         }
  782.                 }
  783. #endif /*!SLOW_AGA_RADIO_DRAW*/
  784.         }
  785.     else
  786.         {
  787.             Rect tempRect;
  788.             
  789.             tempRect = frame;
  790.             ::InsetRect(&tempRect, 1, 1);
  791.             ::EraseOval(&tempRect);
  792.     
  793.             if (disabled)
  794.                 PenPat(&qd.gray);
  795.             ::FrameOval(&frame);
  796.             if (disabled)
  797.                 PenNormal();
  798.             if (inPushed)
  799.                 {
  800.                     tempRect = frame;
  801.                     ::InsetRect(&tempRect, 1, 1);
  802.                     ::FrameOval(&tempRect);
  803.                     ::PenNormal();
  804.                 }
  805.     
  806.             if (mValue)
  807.                 {
  808.                     if (mValue == 1)
  809.                         {
  810.                             tempRect = frame;
  811.                             ::InsetRect(&tempRect, 3, 3);
  812.                             ::FillOval(&tempRect, &qd.black);
  813.                         }
  814.                     else
  815.                         {
  816.                             ::MoveTo(frame.left + 3, frame.top + 5);
  817.                             ::LineTo(frame.right - 4, frame.top + 5);
  818.                             ::MoveTo(frame.left + 3, frame.top + 6);
  819.                             ::LineTo(frame.right - 4, frame.top + 6);
  820.                         }
  821.                 }
  822.         }
  823. }
  824.  
  825. void LAGARadioButton::DrawText ()
  826.  
  827. {
  828.     StColorPenState theState;
  829.     // Retrieve info about font again.
  830.  
  831.     Int16 just = UTextTraits::SetPortTextTraits(mTextTraitsID);
  832.     
  833.     Rect frame;
  834.     CalcLocalFrameRect(frame);
  835.     frame.left += kRadioWidth + 5;
  836.     frame.top -= 2;
  837.     frame.bottom--;
  838.     if (UEnvironment::HasFeature(env_SupportsColor))
  839.         {
  840.             RGBColor textColor;
  841.             ::GetForeColor(&textColor);
  842.     
  843.             ApplyForeAndBackColors();
  844.             if (mEnabled == triState_On)                                                                                                                                //    <06/27/96    ca>
  845.                 ::RGBForeColor(&textColor);
  846.             else
  847.                 ::RGBForeColor(&gAGAColorArray[7]);
  848.         }
  849.     UTextDrawing::DrawWithJustification((Ptr)&mTitle[1], mTitle[0], frame, just);
  850. }
  851.  
  852. //-------Utilities--------------------------------------------------------------------------------------------------
  853.  
  854. StringPtr LAGARadioButton::GetDescriptor (Str255 outDescriptor) const
  855.  
  856. {
  857.     return LString::CopyPStr(mTitle, outDescriptor);
  858. }
  859.  
  860. void LAGARadioButton::SetDescriptor (ConstStr255Param inDescriptor)
  861.  
  862. {
  863.     mTitle = inDescriptor;
  864.     Refresh();
  865. }
  866.  
  867. void LAGARadioButton::SetValue (Int32 inValue)
  868.  
  869. {
  870.     if (inValue < mMinValue)
  871.         inValue = mMinValue;
  872.     else
  873.         if (inValue > mMaxValue)
  874.             inValue = mMaxValue;
  875.     mValue = inValue;
  876.     // If turning RadioButton on, broadcast message so that the
  877.     // RadioGroup (if present) will turn off the other RadioButtons
  878.     // in the group.
  879.     
  880.     if (inValue == Button_On)
  881.         {
  882.             BroadcastValueMessage();
  883.             BroadcastMessage(msg_ControlClicked, (void*) this);
  884.         }
  885.     FocusDraw();
  886.     DrawGraphic();
  887. }
  888.  
  889. void LAGARadioButton::HotSpotAction (Int16 /*inHotSpot*/, Boolean inCurrInside, Boolean inPrevInside)
  890.  
  891. {
  892.     // Draw if cursor moved from IN to OUT
  893.     //   or from OUT to IN
  894.     if (inCurrInside != inPrevInside)
  895.         {
  896.             FocusDraw();
  897.             DrawGraphic(inCurrInside);
  898.         }
  899. }
  900.  
  901. void LAGARadioButton::HotSpotResult (Int16 /*inHotSpot*/)
  902.  
  903. {
  904.         // In the Mac interface, clicking on a RadioButton always
  905.         // turns it on (or leaves it on). The standard way to turn
  906.         // off a RadioButton is to turn on another one in the
  907.         // same Radio Group. A Radio Group will normally be a
  908.         // Listener of a RadioButton.
  909.          
  910.     SetValue(Button_On);
  911. }
  912.  
  913.  
  914.